home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
STARS3D.ZIP
/
MCGA.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-12-22
|
2KB
|
94 lines
Unit MCGA;
Interface
Uses Crt;
Procedure Gmode;
Procedure Tmode;
Procedure Flip;
Procedure PutPixel(X,Y : Word; Col : byte; Where : Word);
Procedure SetPal(Col,R,G,B : Byte);
Procedure Clscr(Col : Word);
Const VGA = $A000;
Type
VScr = ^VirtScreen;
VirtScreen = Array[1..64000] Of Byte;
Var
VirScr : VScr;
VirAddr : Word;
Implementation
Procedure Gmode;
Begin
asm
mov ax,13h
int 10h
end;
GetMem(VirScr,64000);
VirAddr := Seg(VirScr^);
Fillchar(VirScr^,64000,0);
end;
Procedure Clscr(Col : Word);
Begin
Fillchar(VirScr^,64000,Col);
end;
Procedure Tmode;
Begin
asm
mov ax,3h
int 10h
end;
Freemem(VirScr,64000);
end;
Procedure Flip;assembler; {to make virtual Flip(Source,Dest : Word}
asm
push ds {STORE DS REGISTER}
mov ax,$0a000 {ADDRESS VIDEO MEMORY}
mov es,ax {MOV IT TO EXTRA SEG dont know why yet}
xor di,di {CLEAR DI/SI = 0 = MOV DI,0}
xor si,si
mov ds,Viraddr {ADDRESS THE VIRTUAL SCREEN swap ax and ds to reverse screens}
mov cx,64000 {SET A LOOP OF 64k SCREEN}
rep movsw {REPEAT IT MOV WORD dont know what it does}
pop ds
{Move(VirScr^,Mem[VGA:0],64000); }
end;
Procedure SetPal(Col,R,G,B : Byte); assembler;
asm
mov dx,$3c8 {Port[$3c8] := Col}
mov al,[Col]
out dx,al {Dx Data Reg / I/O}
mov dx,$3c9 {Inc Dx May Be Faster}
mov al,R {Port[$3c9] := R}
out dx,al
mov al,G {Port[$3c9] := G}
out dx,al
mov al,B {Port[$3c9] := B}
out dx,al
end;
Procedure PutPixel(X,Y : Word; Col : Byte; Where : Word);
Begin
{Asm Way Is Much Longer And Pointless To Me At The Moment}
Mem[Where:Y*320+X] := Col
end;
end.